package com.ysd.lis.service.lab.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ysd.common.Result;
import com.ysd.lis.entity.lab.LabReqdetail;
import com.ysd.lis.entity.lab.LabReqdetailDel;
import com.ysd.lis.mapper.lab.LabReqdetailDelMapper;
import com.ysd.lis.request.LabReqdetailDetailDto;
import com.ysd.lis.service.lab.LabReqdetailDelService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;


/**
 * <p>
 * 申请明细表 服务实现类
 * </p>
 *
 * @author prs
 * @since 2024-10-24
 */
@Service
public class LabReqdetailDelServiceImpl extends ServiceImpl<LabReqdetailDelMapper, LabReqdetailDel> implements LabReqdetailDelService {

    @Override
    public Result batchAddReqDetailList(LabReqdetailDetailDto dto) {
        List<LabReqdetailDel> labReqdetailList = dto.getLabReqdetailList();
        boolean b = this.saveBatch(labReqdetailList);
        if (b) {
            return Result.succ(1, "添加成功", null);
        } else {
            return Result.fail(400, "添加失败", "");
        }
    }

    @Override
    public Result batchDetelReqDetailList(LabReqdetailDetailDto dto) {
        List<LabReqdetailDel> labReqdetailList = dto.getLabReqdetailList();
        List<String> ids = labReqdetailList.stream().map(LabReqdetailDel::getId).collect(Collectors.toList());
        boolean b = this.removeByIds(ids);
        if (b) {
            return Result.succ(1, "删除成功", null);
        } else {
            return Result.fail(400, "删除失败", "");
        }
    }
}
